#if !defined(CHESS_GAME_H)
#define CHESS_GAME_H

#include <fstream>
#include <iostream>
using namespace std;
#include <string>
#include "MoveHistory.h"
#include "Cell.h"
#include "Piece.h"
#include "Pieces.h"
#include "Board.h"

class MoveHistory;
class MoveRecord; 
class ChessGame {

	public:
		/// Allocates a Board, a collection of Pieces,
		/// an empty Piece
		ChessGame();
		ChessGame(const char* filePointer);

		/// Calls destructors on each heap-allocated member
		~ChessGame();
		
		Cell* GetCell(int row, int col);
		Piece* GetPiece(int row, int col);
		
		Pieces* GetPieces();

		PieceColor GetCurrentPlayersColor();
		void SetGameMode(char *  newMode);

		
		bool CellHasCurrentPlayersPiece(Cell* cell);
		
		MoveRecord* Move(Piece* piece, Cell* destCell);
		void UndoMove(MoveRecord* record);
		
		/// Checks if this player is in check
		bool PlayerInCheck(PieceColor playersColor);
		bool PlayerInCheckMate(PieceColor playersColor);
		
		/// Returns a new set of valid cells we can move to
		std::set<Cell*>* GetValidMoves(Piece* piece);
		bool IsValidMove(Piece* piece, Cell* destCell);
		

		bool MoveEndsUpInCheck(Piece* piece, Cell* cell, PieceColor playersColor);
		MoveRecord* TempMove(Piece* piece, Cell* destCell) ;
		MoveRecord* PopMostRecentMoveRecord();
		bool currentPlayerIsHuman();
		PieceColor GetOtherPlayersColor();
		bool saveToXml(std::string loc);
		
	private:
		Board* board;
		Pieces* pieces;
		
		int gameMode;
		PieceColor currentPlayersColor;
		MoveHistory* moveHistory;
		bool loadFromXml(const char* filePointer);
		string whitePlayer;
		string blackPlayer;

};

#endif
